<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <div class="container">
        <a class="navbar-brand" href="{{ url_for('index') }}">ByUsi短链服务</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav me-auto">
                <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('index') }}">首页</a>
                </li>
                {% if 'user' in session %}
                <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('dashboard') }}">仪表盘</a>
                </li>
                {% endif %}
                {% if 'user' in session and user.get('is_admin') %}
                <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('admin_dashboard') }}">管理</a>
                </li>
                {% endif %}
            </ul>
            <ul class="navbar-nav">
                {% if 'user' in session %}
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-bs-toggle="dropdown">
                        {{ user.username }}
                    </a>
                    <ul class="dropdown-menu dropdown-menu-end">
                        <li><a class="dropdown-item" href="{{ url_for('dashboard') }}">我的仪表盘</a></li>
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item" href="{{ url_for('logout') }}">退出登录</a></li>
                    </ul>
                </li>
                {% else %}
                <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('login') }}">登录</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('register') }}">注册</a>
                </li>
                {% endif %}
            </ul>
        </div>
    </div>
</nav>